package annotation;

import java.lang.reflect.Method;
import java.util.Scanner;

public class AnnotationDemo {
    public static void main(String[] args) throws Exception{
        Scanner scan = new Scanner(System.in);
        String fileName = scan.nextLine();
        Class clazz = Class.forName(fileName);
        Object obj = clazz.newInstance();
        Method[] methods = clazz.getDeclaredMethods();
        for (Method mh:methods) {
            //获得加在方法前的@Test注解
            Test test = mh.getAnnotation(Test.class);
            System.out.println("test注解:"+test);
            //只调用带有@Test的方法
            if(test!=null){
                mh.invoke(obj);
                //获取@Test的各个属性值
                String v1 = test.value();
                int v2 = test.number();
                System.out.println(v1+":"+v2);
            }
        }
        System.out.println("123123123");
    }
}